package com.tpo.jnotes.base.controls;

import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;

public class BIconButton extends JButton
{
    private ImageIcon rolloverIcon;
    private ImageIcon pressedIcon;

    public BIconButton( ImageIcon icon, String command )
    {
        super( icon );
        setMargin( new Insets( 0, 0, 0, 0 ) );
        setRolloverEnabled( true );
        setAllIcons( icon );
        setIconTextGap( 0 );
        setBorder( BorderFactory.createEmptyBorder() );
        setFocusPainted( false );
        setContentAreaFilled( false );
        setActionCommand( command );
    }

    private void setAllIcons( ImageIcon icon )
    {
        setIcon( icon );
        setDisabledSelectedIcon( icon );
        setRolloverIcon( icon );
        setRolloverSelectedIcon( icon );
        setSelectedIcon( icon );
    }

    public ImageIcon getCustomRolloverIcon()
    {
        return rolloverIcon;
    }

    public void setCustomRolloverIcon( ImageIcon rolloverIcon )
    {
        this.rolloverIcon = rolloverIcon;
        setRolloverIcon( rolloverIcon );
        setRolloverSelectedIcon( rolloverIcon );
    }

    public ImageIcon getCustomPressedIcon()
    {
        return pressedIcon;
    }

    public void setCustomPressedIcon( ImageIcon pressedIcon )
    {
        this.pressedIcon = pressedIcon;
        setPressedIcon( pressedIcon );
    }
}
